package com.example.dto;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import org.springframework.security.oauth2.jose.jws.SignatureAlgorithm;

import java.io.IOException;

public class SignatureAlgorithmSerializer extends JsonSerializer<SignatureAlgorithm> {

    @Override
    public void serialize(SignatureAlgorithm value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
        if (value != null) {
            gen.writeString(value.getName()); // 将枚举转换为字符串
        } else {
            gen.writeNull();
        }
    }
}